package practice02;

/**
 * @author Administrator
 * @version V1.0
 * @ProjectName:IntelliJ IDEA
 * @PackageName: practice02
 * @ClassName: Book
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @date 2019/12/5 19:35
 * @Copyright 大牛版板所有
 */
public class Book {
    private String bookId; // 图书编号
    private String bookName;
    private String press;
    private double price;

    // 创建构造函数初始化
    public Book(String bookId, String bookName, String press, double price) {
        this.setBookId(bookId);
        this.setBookName(bookName);
        this.setPress(press);
        this.setPrice(price);
    }

    // 设置get/set方法
    public String getBookId() {
        return bookId;
    }
    public void setBookId(String bookId) {
        this.bookId = bookId;
    }

    public String getBookName() {
        return bookName;
    }
    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public String getPress() {
        return press;
    }
    public void setPress(String press) {
        this.press = press;
    }

    public double getPrice() {
        return price;
    }
    public void setPrice(double price) {
        if (price>0){
            this.price = price;
        }
        else{
            System.out.println("图书的价格必须大于0！");
        }
    }
    // 声明方法
    public void report(){
        System.out.println(this.getBookName()+"~图书的编号为："+this.getBookId()+"，出版社为："+
                this.getPress()+"，价格为："+this.getPrice());
    }



    // 静态方法
    public static void main(String[] args) {
        Book book = new Book("0001","狼道","新华出版社",45);
        book.report();
    }
}
